home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS18.ADF / Logo / logo.doc < prev    next >
Text File  |  1989-01-27  |  19KB  |  586 lines

  1.     ALOGO - ⌐ 1986 by Gerald Owens
  2.  
  3.     Permission is given for free, non-commercial distribution.
  4. This software is TRUE shareware:  If you have contributed something
  5. to the public domain, then you can keep it for free!  Otherwise, it is
  6. requested that you send a tax deductible donation of $5.00 to:
  7.  
  8.                Wycliffe Associates
  9.                Box 2000
  10.                Orange, Ca.   92669-9984
  11.  
  12.  
  13.     Specify that the money is to go for literacy training in less
  14. developed countries, and tell them that "S" sent you.  Be sure to tell
  15. them not to send further information if you don't want it.
  16. Please direct all bug reports and suggestions for improvements to:
  17.  
  18.                Gerald Owens                   Gerald Owens
  19.                C/O William Richardson         C/O Amiga Atlanta
  20.                1599 Council Bluff Dr.         Box 7724
  21.                Atlanta, Ga.  30345            Atlanta, Ga.  30357
  22.  
  23.  
  24. LIMITATIONS
  25.  
  26.      This is just the graphics portions of LOGO.  I have tried to
  27. follow the Apple II LOGO commands as closely as possible, with the
  28. exception of file, editor, and printer related commands.  Any good
  29. book on LOGO should be of help.
  30.  
  31.  
  32. PROBLEM AREAS
  33.  
  34.      A single window is used for the editor, command, and graphics
  35. window.  Wierd things happen to the "turtle" when things get scrolled.
  36.  
  37.      Do not panic!  Repeat, do NOT panic if after successfully executing
  38. a procedure, you re-edit the buffer and find a blank screen!  The
  39. editor is fixed to place the cursor in front of the NEXT statement
  40. to be executed.  If there is an error, the cursor will be in front
  41. of the offending statement.  When a procedure returns, the cursor
  42. is temporarily placed after the END or the OUTPUT statement, so if
  43. the last procedure executed was the last procedure in the editor
  44. buffer, the cursor will be placed after the END statement, and so
  45. may appear alone on a blank screen.  Just press SHIFT-UP ARROW to
  46. get to your code.
  47.  
  48.      The editor is not very good.  I hope that if a later version comes
  49. out, it will be worthy of alternate use as a programmer's editor.
  50.  
  51.      The program polls the window message port constantly for a keypress
  52. while it executes, so that it can stop at a keypress.  Unfortunately,
  53. this takes up so much CPU time that it is virtually unable to be
  54. multi-processed.  My apologies.  I'm sure there's a work-around, but
  55. the Amiga is such a complicated machine that it will probably take a
  56. while for me to get sophisticated enough to implement it in assembler.
  57.  
  58.      There are no global variables.  All procedure variables are
  59. sort of local/global.  They're global in the sense that they are
  60. accessible outside of the procedure, and local in the sense that
  61. when a procedure is entered, the old value is saved, and when the
  62. procedure is exited, the old value is restored.  Every unique variable
  63. name is placed in a table and all accesses refer to that central
  64. copy, so the scope can be classified as being dynamic.  If you want
  65. global variables, declare a dummy procedure with "local" variables
  66. having the names of the desired global variables.
  67.  
  68.      Procedures and variables are declared using the editor.  They
  69. cannot be declared from the command processor.  When declaring a
  70. procedure, the header (TO <name> <vars>) MUST START on separate lines.
  71.  
  72.  
  73. HOW TO RUN
  74.      ALOGO cannot be executed from the Workbench.  Rather, get into the
  75. CLI and type in:
  76.  
  77. logo
  78.  
  79. [Note:  To open the CLI, it must be turned "On" in Preferences.  Then
  80. reboot.  The CLI icon will be in the System drawer of that Workbench disk.
  81. Click on it.  Enter "cd AMICUS_#18:logo" and then "logo" as above.]
  82.            
  83.  
  84. GENERAL COMMANDS
  85.  
  86.    These commands are in addition to the regular ALOGO commands, but
  87. only one command can be typed in on a line.
  88.  
  89. NEW
  90.    Clear the editor buffer.  Will prompt if contents have been
  91.    changed and not saved.
  92.  
  93. LOAD filename
  94.    Clears the editor buffer and loads the text file into the
  95.    editor buffer.  If the previous contents of the buffer was
  96.    changed and not saved, the computer will ask if it is OK
  97.    to delete the file.
  98.    ***WARNING*** Do not use a file name with an embedded blank.
  99.                  Even if it has ""'s around it!
  100.  
  101. SAVE
  102.    Without a file name, saves the editor buffer with the same
  103. name as it was previously loaded or saved under.
  104.  
  105.  
  106. SAVE filename
  107.    Saves the editor buffer under the new name, and records it so that
  108. "SAVE" without a file name saves under that file name.
  109.  
  110.  
  111. EDIT
  112.    Edit the editor buffer.  Press function key 'F1' to excape from the
  113. editor
  114.  
  115.  
  116. LIST
  117.    List the contents of the editor buffer on the screen.  Pressthe Right
  118. Mouse Button to temporarily stop the listing, and release it to
  119. allow the listing to continue.
  120.  
  121.  
  122. LLIST
  123.    Same as LIST, but the contents of the editor buffer are printed
  124. on the printer attached to your Amiga, followed by a Page-Eject.
  125.  
  126.  
  127. FILES
  128.    Same as the AmigaBASIC "FILES" command.  Lists the files in the
  129. current directory on the screen.  Requires that the "DIR" command be
  130. in the "C:" directory.
  131.  
  132.  
  133. QUIT
  134.    Leave logo and return to the operating system.
  135.  
  136.  
  137.  
  138. EDITOR COMMANDS
  139.    Use the cursor keys to move up, down, left, and right.
  140.    Shift up-cursor moves the cursor up 10 lines.
  141.    Shift down-cursor moves the cursor down 10 lines.
  142.    Shift left-cursor move the cursor to the beginning of the line.
  143.    Shift right-cursor moves the cursor to the end of the line.
  144.    The grey DEL key deletes the character under the cursor.
  145.    The BACKSPACE key deletes the character just before the cursor.
  146.    Shift DEL key deletes an entire line.
  147.    Press RETURN to get a new line, or make a line into two lines.  Sorry,
  148.       no way to join two lines together as yet.
  149.    CTRL-Q, CTRL-X and F1 exits from the editor.
  150.  
  151.  
  152.  
  153. EXPRESSIONS
  154.    An element can be any of the following:
  155.  
  156.    a.  A signed integer number (32 bits).  (-235, 447)
  157.    b.  A built-in variable.  (XCOR, YCOR, HEADING, and PENCOLOR.)
  158.    c.  A procedure call.  See the ALOGO command "OUTPUT" on how to
  159.        make a procedure return a value.  (COORD, FAC 4, DDT 77+2 99.)
  160.    d.  A user defined variable.  These start with a ":", followed by
  161.        a letter, and then followed by an optional sequence of letters
  162.        and digits.  (:a , :a1e2b4, :zzz).
  163.    
  164.    (As in the rest of ALOGO, it does not matter if the letters are
  165. in upper or lower case.  Thus, xcor, XCOR, and XcOr are all the same.)
  166.  
  167.    An expression is an element or an algebraic expression using elements.
  168. The following are valid expressions:
  169.  
  170.    5
  171.    :a+5
  172.    3*(:a-7)
  173.    :z/-9+ fac 6    (Procedure call of fac 6.  Result is added to :z/-9)
  174.    :Q % 6          (Remainder of :Q divided by 6)
  175.    -:r             (Negative of the value of :r)
  176.    xpos+4          (The value of built-in variable xpos has 4
  177.                     added to it)
  178.  
  179.    The following are valid operators to use in an expression.  They
  180. all behave the same as they do in AmigaBASIC.
  181.  
  182.    <  -  Less than, for comparing two numbers.
  183.    =  -  Equal to, for comparing two numbers.
  184.    >  -  Greater than, for comparing two numbers.
  185.    AND - Logical AND.
  186.    OR -  Logical OR.
  187.    NOT - Logical NOT.
  188.    *  -  Multiplication
  189.    /  -  Division
  190.    %  -  Modulo.  Same as MOD in AmigaBASIC.
  191.    +  -  Addition
  192.    -  -  Subtraction and negation.
  193.  
  194.    The precedence is as follows (same as for BASIC)
  195.  
  196.    ()'s        (To change the order of the precedence)
  197.    -           (Negation.)
  198.    * , / , %   (Same precedence.  Done left to right.  So 2*3*5/6 is
  199.                 (((2*3)*5)/6). )
  200.    + , -       (Same precedence.  Also done left to right.)
  201.    <,=,>       (Note:  <=,=>, and <> are NOT permitted.)
  202.    NOT
  203.    AND         (Done left to right.)
  204.    OR          (Done left to right.)
  205.  
  206.    Remember that ALOGO does not use anything to separate different
  207. expressions.  This can cause problems when using negation.
  208. As an example, if it is desired to print out 1 and -1 on the
  209. same line, the following command will NOT work:
  210.  
  211.    PRINT [1 -1]
  212.  
  213. It will print out 0, since 1-1 is 0.  To get 1 and -1 to be printed
  214. out separately, one must use:
  215.  
  216.    PRINT [1 (-1)]
  217.  
  218.  
  219.  
  220. ALOGO BUILT-IN VARIABLES
  221.  
  222.    The following are the ALOGO built-in variables.  They hold the values
  223. of different aspects of the drawing pen.
  224.  
  225.  
  226. XCOR
  227.  
  228.    Holds the horizontal coordinate of the pen.  It will normally range
  229. from 0 to 610 in value.  0 is for the far left of the window, and
  230. 610 is for the far right of the window.
  231.  
  232.  
  233. YCOR
  234.  
  235.    Holds the vertical coordinate of the pen.  It will normally range
  236. from 0 to 182 in value, 0 is for the top of the window, and 182 is
  237. for the bottom of the window.
  238.  
  239.  
  240. HEADING
  241.  
  242.    Holds the heading of the pen, which is the direction in which the
  243. pen will move if given a FORWARD or BACK command.  It will range in
  244. value from 0 to 359.
  245.  
  246.  
  247. PENCOLOR
  248.  
  249.    Holds the present drawing color of the pen.  This will be a value
  250. from 0 to 3.  The exact color drawn will depend on the colors set in
  251. the preferences menu.
  252.  
  253.  
  254.  
  255. ALOGO COMMENTS
  256.  
  257.    All ALOGO comments start with a ';', and continue to the end of the
  258. line, and can appear in any line.  For example:
  259.  
  260.          CS PD FD 10 ; this will not be executed >> LT 90 FD 10
  261.  
  262. will draw a line 10 steps long, but will not add the second line going
  263. to the left at the end of the first line.
  264.  
  265.  
  266. ALOGO COMMANDS
  267.  
  268.    The following commands can be typed in at the '>' prompt.  More
  269. than one command can be typed in on the same line.  To stop execution
  270. of the commands or any procedures, press a key on the Amiga keyboard.
  271.  
  272.    The words 'exp', 'exp1', 'exp2', and 'exp3' represent valid expressions
  273. as outlined above.  If none of these appear in the command, then the
  274. command does not take any parameters.
  275.  
  276.    Some of the commands can take a 2 letter abbreviation.  They can also
  277. be typed in in any mix of upper and lower case letters.
  278.  
  279.  
  280. CS
  281. CLEARSCREEN
  282.  
  283.    Clear the screen, put the drawing pen at the center of the screen,
  284. and set the direction to 0 degrees (up).  The pen is left up or down.
  285.  
  286.  
  287. HOME
  288.  
  289.    Put the drawing pen at the center of the screen and set the direction
  290. to 0 degrees (up).  The pen is left either up or down.
  291.  
  292.  
  293. CLEAN
  294.  
  295.    Just clear the screen, without affecting the pen location or whether
  296. the pen is up or down.
  297.  
  298.  
  299. PU
  300. PENUP
  301.  
  302.    Reset the pen so that the pen will not draw lines when moved.
  303.  
  304.  
  305. PD
  306. PENDOWN
  307.  
  308.    Set the Pen so that if the pen is moved, lines will be drawn.
  309.  
  310.  
  311. SETPC exp
  312.  
  313.    Set the pen color to the value of (exp % 4).  Pen colors are dependent
  314. on the Preferences settings, but they will map to the following colors
  315. on all screens:
  316.  
  317.             0 - Background color.
  318.             1 - Color of the letters and the border.
  319.             2 - Color of the Depth Arranger gadget in the upper
  320.                 right corner of the window.
  321.             3 - Color of the cursor.
  322.  
  323.  
  324. SETPOS [exp1 exp2]
  325.  
  326.    Set the pen to be at horizontal coordinate exp1, and vertical coordinate
  327. exp2.  (0,0) is at the upper left corner of the outside of the window, and
  328. (610,182) is at the lower right corner of the window.  If the pen is
  329. down, a line is drawn from the previous position to the new position.
  330. THE "[]"'S AROUND THE TWO EXPRESSIONS ARE MANDATORY.
  331.  
  332.  
  333. DOT [exp1 exp2]
  334.  
  335.    Places a dot of the present pen color at horizontal coordinate exp1
  336. and vertical coordinate exp2.  Exp1 can range from 0 to 610, and exp2
  337. can range from 0 to 182.  THE "[]"'s AROUND THE
  338. TWO EXPRESSIONS ARE MANDATORY.
  339.  
  340.  
  341. SETX exp
  342.  
  343.    Like SETPOS, but sets the horizontal coordinate only, leaving the
  344. vertical coordinate alone.  If the pen is down, then a line is drawn to
  345. the new position from the old position.
  346.  
  347.  
  348. SETY exp
  349.  
  350.    Like SETPOS and SETX, but sets the vertical coordinate only, leaving
  351. the horizontal coordinate alone.  If the pen is down, then a line is drawn
  352. to the new position from the old position.
  353.  
  354.  
  355. FD exp
  356. FORWARD exp
  357.  
  358.    Move in the direction of the heading of the pen (exp) many 'steps'.
  359. (There are 182 steps vertically and 304 horizontally.)  If the pen
  360. is down draw a line.  Note from SETPOS that a step in the horizontal
  361. direction is doubled.  This makes the aspect ratio close to 1:1, so
  362. that the logo statements "FD 10 LT 90 FD 10 LT 90 FD 10 LT 90 FD 10"
  363. forms more of a square than a rectangle.
  364.  
  365.  
  366. BK exp
  367. BACK exp
  368.  
  369.    Move in the opposite direction of the heading of the pen (exp)
  370. many 'steps'.  BK exp is the same as FD -(exp).
  371.  
  372.  
  373. LT exp
  374. LEFT exp
  375.  
  376.    Turn the heading of the pen's heading left (exp) degrees.  Directions
  377. on the screen are:
  378.  
  379.                    left   right
  380.                    <---   --->
  381.                         0
  382.                         ^
  383.                         |
  384.                   270 <-+-> 90
  385.                         |
  386.                         V
  387.                        180
  388.                    <---   --->
  389.                   right   left
  390.  
  391.  
  392. RT exp
  393. RIGHT exp
  394.  
  395.    Turn the heading of the pen's heading right (exp) degrees.  See the
  396. entry for LT and LEFT.   RT exp is the same as LT -(exp)
  397.  
  398.  
  399. SETH exp
  400. SETHEADING
  401.  
  402.    Turn the heading of the pen to the heading of (exp) degrees.  See the
  403. entry for LT and LEFT to see the directions to which the heading will
  404. translate.
  405.  
  406.  
  407. PRINT [ {exp | 'string'} {exp | 'string'} . . . ]
  408.  
  409.     Print the strings or the values of the expressions between the
  410. '[' and the ']'.  There can be as many expressions or as many strings,
  411. in any order, as you wish between the '[' and the ']'.  Strings
  412. *MUST* be surrounded by "'"'s.  The following lines print out
  413. various values.  The results are shown.
  414.  
  415.          PRINT [ 45*7 ' is 315']
  416. result:315  is 315
  417.  
  418.          PRINT ['this' ' is ' 'a' 'test']
  419. result:this is atest                   (put 'a ', rather than 'a', to
  420.                                         avoid this.)
  421.  
  422.          print [1*2 2*2 2*4]
  423. result:2 4 8
  424.  
  425.          PRINT [1*2 '+' 2*3 '=' 2*4]
  426. result:2 +6 =8
  427.  
  428.  
  429. MAKE "var exp
  430.  
  431.    Changes the value of the procedure variable to be the same as exp.
  432. Thus, if the value of :xxt is 17, then executing:
  433.  
  434.    MAKE "xxt :xxt+5
  435.  
  436. will change the value of :xxt to 22.  Note that the ":" is replaced
  437. by a double quote, which is required.  The values of built-in variables
  438. cannot be changed using MAKE.
  439.  
  440.  
  441.  
  442. ALOGO CONTROL STATEMENTS
  443.  
  444.    The following statements affect the flow of control of the program.
  445. Only TO and END can be used in an editor buffer.  All the others can be
  446. typed in directly at the '>' prompt, and in the editor buffer.
  447.  
  448.  
  449. RP exp [stmt stmt ....]
  450. REPEAT exp [stmt stmt ....]
  451.  
  452.    Repeat all the statements between the '[' and the ']' (exp) times.
  453. If exp is less than or equal to 0, the statements between the '[]''s
  454. are not executed.  The following two lines draw the same squares.
  455.  
  456.          CS PD FD 40 LT 90 FD 40 LT 90 FD 40 LT 90 FD 40 LT 90
  457.  
  458.          CS PD REPEAT 4 [FD 40 LT 90]
  459.  
  460.    THE "[]"'s ARE REQUIRED.
  461.  
  462.  
  463. IF exp [true statements] [false statements]
  464. IF exp [true statements]
  465.  
  466.    Tests the value of exp, and if true (not zero) all the statements
  467. between the first set of "[]"'s will be true.  If a second set of
  468. statements are between "[]"'s and are after the first set, they are
  469. skipped.  If the value of exp is false (zero), then the first set
  470. of statements between the "[]"'s is skipped, and the second set of
  471. statements between the second pair of "[]"'s is executed.  If a second
  472. set of statements does not exist (as in the second IF statement), then
  473. there is no error.  There IS an error if the "[]"'s are missing, or
  474. if there is no first set of statements.
  475.  
  476.  
  477. TO procedurename :variable :variable ....
  478. .
  479. .
  480. END
  481.  
  482.    Define a procedure named procedurename, with the variables after it
  483. as parameters.  Procedures cannot be defined directly, but must be typed
  484. into the editor buffer.
  485.  
  486.    TO *MUST* be at the beginning of the line, but END does not have to be on
  487. it's own line.  Failure to do so will cause ALOGO to complain that a
  488. procedure has not been defined.
  489.  
  490.    When the procedurename and parameters are typed in (using the same syntax
  491. as all the built-in commandss), all the statements between the TO and the
  492. END will be executed.
  493.  
  494.    ALOGO variables begin with a ':' followed by a letter, and can be
  495. composed of letters and digits.  ALOGO will not distinguish between
  496. upper and lower case letters, either in the procedure name or the
  497. variable names.
  498.  
  499.    Examples:
  500. ((these are typed into the editor buffer))
  501.  
  502.       to square :x  ;draw a square :x units on a side.
  503.          FD :x LT 90 FD :x LT 90 FD :x LT 90 FD :x LT 90
  504.       end
  505.  
  506.       to multisquare :x1 :turn :x   ;draw :x squares :x1 units on a side
  507.                                     ;turning :turn degrees between each
  508.                                     ;drawn square.
  509.          RP :x [square :x1 LT :turn]  ; this :x will not be confused with
  510.                                       ; the :x in square.  They are
  511.                                       ; different variables.
  512.       end
  513.  
  514. ((these are typed in at the '>' prompt))
  515.  
  516.      >square 50             ;draws a square 50 units on a side
  517.      >multisquare 30 10 36  ;draws 36 squares that are 30 units on a side
  518.                             ;turning 10 degrees between each square
  519.  
  520.    Trying to execute a procedure that is not defined in the editor buffer
  521. will cause ALOGO to complain.
  522.  
  523.    ALOGO procedures are like AmigaBASIC subroutines, and do not normally
  524. return a value.  To make a procedure return a value, so that it can be
  525. used in an expression, see the "OUTPUT" statement.
  526.  
  527.    ALOGO procedures can call other procedures, and can even call
  528. themselves.
  529.  
  530.  
  531. OUTPUT  exp
  532.  
  533.    To make a procedure return a value, use the OUTPUT statement.  The
  534. value returned will be the value of exp.  Some examples are:
  535.  
  536.    ((The following lines are typed into the Editor Buffer))
  537.  
  538.    to sum3 :x :y :z            ;return the sum of :x, :y, :z
  539.       output :x+:y+:z
  540.    end
  541.  
  542.    ((the following lines are typed at the ">" prompt.))
  543.  
  544.    >print [5*sum3 1 2 3]       ;do 5*(1+2+3)
  545. 30
  546.  
  547.    >print [sum3 1 2 3]         ;do 1+2+3
  548. 6
  549.  
  550.    The OUTPUT statement can be used anywhere, even in a set of statements
  551. between "[]"'s in the IF and REPEAT statements.  The execution of the
  552. IF or the REPEAT will be terminated, and the value returned to the
  553. procedure that called the procedure.  It is sort of like the AmigaBASIC
  554. RETURN statement.
  555.  
  556.  
  557. STOP
  558.  
  559.    Like the OUTPUT statement, the STOP statement stops the execution
  560. of a procedure and returns to the procedure that called the original
  561. procedure.  It is exactly like the AmigaBASIC RETURN statement.
  562.  
  563.  
  564. HALT
  565.  
  566.    This is like the AmigaBASIC STOP statement.  It stops the execution
  567. of all procedures and returns to the ">" prompt.  Pressing a key on
  568. the Amiga keyboard will have the same effect.
  569.  
  570.  
  571.  
  572.  
  573. FINAL NOTES
  574.  
  575.      ALOGO V1.0 is written entirely in assembly language, which
  576. accounts partly for its speed and partly for its rough edges, since
  577. most of the programming examples provided by Commodore are oriented
  578. towards "C".  The headers of the procedures are partly compiled into
  579. a table for quick lookup, and are tied directly to the source code
  580. in the editor.  Changing a line in the editor forces this table to
  581. be recompiled.  I could have compiled all the procedures in the
  582. editor buffer in their entirety, but there would have been no direct
  583. connection between errors in the compiled code and where the error
  584. was located in the source.  Thus, in a child-oriented language, I opted
  585. for making the location of errors easy to do.
  586.